<template>
	<view class="content">
		<scroll-view scroll-x class="tabs-content" enable-flex scroll-with-animation>
			<view class="order-nav">
				<view class="nav-item" v-for="(nav, index) in orderState" :key="index" @tap="onNav(nav.id, index)">
					<view class="item-title" :class="{ 'item-title-active': tabindex === index }">{{ nav.title }}</view>
					<view class="nav-line" :class="{ 'line-active': tabindex === index }"></view>
				</view>
			</view>
		</scroll-view>
		<mescroll-body ref="mescrollRef"  @init="mescrollInit" @down="downCallback" @up="upCallback">
		<view class="balance-list">
			<view class="balance-item" v-for="(item, index) in resultList" :key="index">
				<view class="balance-left">
					<view class="balance-status">{{item.type_name}}</view>
					<view class="balance-time">{{item.created_at}}</view>
				</view>
				<view class="balance-right">
					{{item.amounts}}
				</view>
			</view>

		</view>
		</mescroll-body>
	</view>
</template>

<script>
	import MescrollMixin from "@/components/mescroll-uni/mescroll-mixins.js";
	export default {
		mixins: [MescrollMixin],
		data() {
			return {
				tabindex: 0,
				orderState: [{
						id: '',
						title: '全部',
					},
					{
						id: 0,
						title: '申请中',

					},
					{
						id: 1,
						title: '待打款',
					},
					{
						id: 2,
						title: '已打款',
					},
					{
						id: -1,
						title: '已作废',
					},
				],
				prams: {
					status: 0,
					page: 1,
				},
				resultList: [],
			};
		},
		onLoad() {
			// this.getWithdrawalHistryList();
		},
		methods: {
			onNav(id, index) {
				this.tabindex = index;
				this.prams.status = id;
				
				this.downCallback();
			},
			// 下拉刷新列表
			downCallback() {
				this.mescroll.resetUpScroll(); // 重置列表为第一页 (自动执行 page.num=1, 再触发upCallback方法 )
			
			},
			/*上拉加载的回调*/
			upCallback(page) {
				this.prams.page = page.num;
				this.$http.get('user.withdrawalHistryList', {
					status: this.prams.status,
					page: this.prams.page,
				}).then(res => {
					let curPageData = res.data.data;
					let curPageLen = curPageData.length;
					let totalCount = res.data.total;
					if (page.num == 1) this.resultList = []; //如果是第一页需手动置空列表
					this.resultList = this.resultList.concat(curPageData); //追加新数据
					this.mescroll.endBySize(curPageLen, totalCount);
				})
				// 获取轮播图数据
			
			},
			// getWithdrawalHistryList() {
			// 	this.$http.get('user.withdrawalHistryList', {
			// 		status: this.prams.status
			// 	}).then(res => {
			// 		this.resultList = res.data.data;
			// 	})
			// }
		}
	}
</script>

<style lang="scss">
	@import './balance-histry-list.scss';
</style>
